/* 首席服务员-服务清单 */
import {
    getPolicyAPI,
    getPolicyTypeAPI,
} from "../../api/article";

import { ref, onMounted, watch } from 'vue'
import { getChiefServerListAPI, getAllChiefListAPI } from "../../api/chief";

/**
 * @description: 列表数据 
 * @param {any} filters 筛选条件
 * @return {*}
 */
export default function useTable(filters: any) {
    const tableData = ref([]);
    const loading = ref(false);
    const totalCount = ref(0);
    const createTime = ref([]);

    // 请求数据
    const query = () => {
        loading.value = true;
        getChiefServerListAPI({ ...filters }).then((res: any) => {
            tableData.value = res.data
            totalCount.value = res.totalCount
            loading.value = false;
        });
    };

    onMounted(() => {
        query();
    })
    watch(filters, query)
    // watch(createTime, (newValue, oldValue) => {
    //     if (newValue !== null && newValue.length) {
    //         filters.createTimeStart = newValue[0];
    //         filters.createTimeEnd = (newValue[1] + 1000 * 60 * 60 * 24 - 1).toString();
    //     } else {
    //         filters.createTimeStart = "";
    //         filters.createTimeEnd = "";
    //     }
    //     query();
    // })

    return {
        tableData,
        loading,
        totalCount,
        createTime,
        query
    }
}